package com.zs.diveinspringbootkotlin.bootstrap

import com.zs.diveinspringbootkotlin.repository.MyFirstLevelRepository
import org.springframework.boot.WebApplicationType
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.context.annotation.ComponentScan

/**
 *
 * @description
 * @author madison
 * @date 2021/6/3 15:58
 *
 */
@ComponentScan(basePackages = ["com.zs.diveinspringbootkotlin.repository"])
class RepositoryBootstrap

fun main(array: Array<String>) {
    val context = SpringApplicationBuilder(RepositoryBootstrap::class.java)
        .web(WebApplicationType.NONE)
        .run(*array)

    // myFirstLevelRepository Bean是否存在
    var myFirstLevelRepository = context.getBean(
        "myFirstLevelRepository",
        MyFirstLevelRepository::class.java
    )
    println("myFirstLevelRepository Bean:$myFirstLevelRepository")

    // 关闭上下文
    context.close()
}